xendom = XendDomain.instance()
if xendom.is_valid_vm(vtpm_struct['VM']):
dom = xendom.get_vm_by_uuid(vtpm_struct['VM'])
- vtpm_ref = dom.create_vtpm(vtpm_struct)
- xendom.managed_config_save(dom)
- return xen_api_success(vtpm_ref)
+ try:
+ vtpm_ref = dom.create_vtpm(vtpm_struct)
+ xendom.managed_config_save(dom)
+ return xen_api_success(vtpm_ref)
+ except XendError:
+ return xen_api_error(XEND_ERROR_TODO)
else:
return xen_api_error(XEND_ERROR_DOMAIN_INVALID)
DEV_MIGRATE_STEP2 = 2
DEV_MIGRATE_STEP3 = 3
+#
+# VTPM-related constants
+#
+
+VTPM_DELETE_SCRIPT = '/etc/xen/scripts/vtpm-delete'
+
#
# Xenstore Constants
#
make_controller = classmethod(make_controller)
+ def destroy_device_state(cls, domain):
+ """Destroy the state of (external) devices. This is necessary
+ to do when a VM's configuration is destroyed.
+
+ @param domain: domain this controller is handling devices for.
+ @type domain: XendDomainInfo
+ """
+ tpmif.destroy_vtpmstate(domain.getName())
+
+ destroy_device_state = classmethod(destroy_device_state)
from xen.xend.XendLogging import log
from xen.xend.XendConstants import XS_VMROOT
from xen.xend.XendConstants import DOM_STATE_HALTED, DOM_STATE_RUNNING
+from xen.xend.XendDevices import XendDevices
from xen.xend.xenstore.xstransact import xstransact
from xen.xend.xenstore.xswatch import xswatch
self._managed_domain_unregister(dominfo)
self._remove_domain(dominfo)
-
+ XendDevices.destroy_device_state(dominfo)
except Exception, ex:
raise XendError(str(ex))
finally:
from xen.xend import XendRoot
from xen.xend.XendLogging import log
from xen.xend.XendError import XendError
-from xen.xend.XendConstants import DEV_MIGRATE_TEST
+from xen.xend.XendConstants import DEV_MIGRATE_TEST, VTPM_DELETE_SCRIPT
from xen.xend.server.DevController import DevController
import os
xroot = XendRoot.instance()
+def destroy_vtpmstate(name):
+ if os.path.exists(VTPM_DELETE_SCRIPT):
+ os.system(VTPM_DELETE_SCRIPT + " " + name)
+
class TPMifController(DevController):
"""TPM interface controller. Handles all TPM devices for a domain.
"""
if uuid:
result['uuid'] = uuid
if type:
- result['type'] == type
+ result['type'] = type
return result